#include<iostream>
#include<string>
#include<pthread.h>
#include<cstdio>
#include<unistd.h>
using namespace std;

//线程分离  

void* thread_run(void* argv)
{
    cout<< static_cast<const char*>(argv) <<"新线程正在执行！"<<endl;
    return nullptr;
}

int main()
{
    pthread_t t1;


    char buf[64];
    snprintf(buf,64,"%s","thread_1：");
    int n = pthread_create(&t1,nullptr,thread_run,(void*)&buf);
    if(n)
        perror("create:");

    pthread_detach(t1);

    int m = pthread_join(t1,nullptr);
    if(m)
    {
        cout<<"线程已分离，等待错误！";
    }   


    return 0;
}
